package com.lxq.opengltest02;

import android.app.ActivityManager;
import android.opengl.GLSurfaceView;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import com.lxq.opengltest02.Renderer.FirstRenderer;

public class MainActivity extends AppCompatActivity {

    private GLSurfaceView glSurfaceView;
    private boolean rendererSet = false;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);


        ActivityManager manager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
        boolean supportEs2 = manager.getDeviceConfigurationInfo().reqGlEsVersion >= 0x20000;

        if (supportEs2) {
            glSurfaceView = new GLSurfaceView(this);
            glSurfaceView.setEGLContextClientVersion(2);
            glSurfaceView.setRenderer(new FirstRenderer(this));
            setContentView(glSurfaceView);
            rendererSet = true;
        }
    }

    @Override
    protected void onPause() {
        super.onPause();
        if (rendererSet) {
            glSurfaceView.onPause();
        }
    }

    @Override
    protected void onResume() {
        super.onResume();
        if (rendererSet) {
            glSurfaceView.onResume();
        }
    }
}
